{include file='public/head'}
<style>
    .layui-layer-btn{
        background-color: #F0F0F0;
    }
</style>
<body>

<div class="x-body">
    <form class="layui-form" id='mainForm' method="post" action="contrastAdd.html">
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>产品属性</label>
            <div class="layui-input-block">
                <input type="text" id="shuxing" name="shuxing" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>自定义属性</label>
            <div class="layui-input-block" style="margin-right: 60px">
                <select name="property" id='property' lay-verify="required" lay-search>
                    <option value="">请选择自定义属性</option>
                    {volist name='list' id='vo'}
                    <option value="{$vo.name}">{$vo.name}</option>
                    {/volist}
                </select>
                <button class="layui-btn layui-btn-sm" style="position: absolute;top:5px;right:-50px;"
                        onclick="propertyAdd('{$Think.get.platform_id}')" type="button">
                    <i class="layui-icon">&#xe654;</i>
                </button>
            </div>
        </div>

        <div class="layui-form-item">
            <div>
                <input type="hidden" name="platform_id" value="{$Think.get.platform_id}">
                <button style="width: 100%" class="layui-btn" lay-submit="" lay-filter="toSubmit">提交保存</button>
            </div>
        </div>

    </form>
</div>
</body>
{include file='public/foot'}
<script type="text/javascript">

    $(document).ready(function () {
        var layer = layui.layer;
        var options = {
            type: 'post',           //post提交
            dataType: "json",        //json格式
            data: {},    //如果需要提交附加参数，视情况添加
            clearForm: false,        //成功提交后，清除所有表单元素的值
            resetForm: false,        //成功提交后，重置所有表单元素的值
            cache: false,
            async: false,          //同步返回
            success: function (data) {
                if (data.code == 0) {
                    layer.msg(data.msg);
                } else {
                    layer.msg(data.msg, {icon: 1, time: 500}, function () {
                        $("#reset").click();
                        x_admin_close();
                        parent.location.reload();
                    });
                }
                //服务器端返回处理逻辑
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                layer.msg('操作失败:服务器处理失败');
            }
        };

        // bind form using 'ajaxForm'
        $('#mainForm').ajaxForm(options).submit(function (data) {
        });

    });
    function propertyAdd(platform_id) {
        layer.open({
            type: 2,
            area: ['500px', '300px'],
            fix: false, //不固定
            maxmin: true,
            shadeClose: false,//是否点击遮罩关闭弹窗
            shade: 0.2,
            resize: true,
            title: '添加自定义属性',
            btn: ['提交'],
            full: true,
            content: "propertyAdd.html?platform_id="+platform_id,
            yes: function (index, obj) {
                layer.getChildFrame('#btn_save', index).click();
                location.reload();
            }
        });
    }

</script>
</html>
